
FIND_PACKAGE(Protoc)

SET(PROTO_DIR ${PROJECT_SOURCE_DIR})

SET(PB_TARGET proto)
ADD_CUSTOM_TARGET(${PB_TARGET}
	#COMMAND ${CMAKE_COMMAND} ARGS -P ${PROTO_COMMAND} abc
	WORKING_DIRECTORY  ${PROTO_DIR}
)

##############################################################
## 设置输出目录											    ##
##############################################################
SET(PB_GO_DIR ${PROJECT_SOURCE_DIR}/common/proto)
SET(PB_CPP_DIR ${PROJECT_SOURCE_DIR}/common/protocpp)
SET(PB_DOC_DIR ${PROJECT_SOURCE_DIR}/docs)
SET(PB_SWAGGER_DIR ${PROJECT_SOURCE_DIR}/install/scenes/hms_api/static/swagger/json)

##公共目录
SET(GOGO_PB_DIR $ENV{GOPATH}/src/github.com/gogo/protobuf/protobuf/) #需要优化调整 

                
#########################
#   hmsai           #
#########################
SET(PB_AI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ai)

file(GLOB_RECURSE  PB_AI_LIST  ${PB_AI_DIR}/*.proto)
SET(PB_AI_OPTS -I$ENV{GOPATH}/src -I${GOGO_PB_DIR} -I${PB_AI_DIR} )

#GO
proto_gen_gogo(TARGET ${PB_TARGET} PLIST ${PB_AI_LIST}  OPTS ${PB_AI_OPTS}   PROTOC_OUT_DIR ${PB_GO_DIR})
#micro
proto_gen_micro(TARGET ${PB_TARGET} PLIST ${PB_AI_LIST}  OPTS ${PB_AI_OPTS}  PROTOC_OUT_DIR ${PB_GO_DIR})
#SWAGGER
proto_gen_swagger(TARGET ${PB_TARGET} PLIST ${PB_AI_LIST}  OPTS ${PB_AI_OPTS}   PROTOC_OUT_DIR ${PB_SWAGGER_DIR} )
#CPP
#proto_gen_cpp(TARGET ${PB_TARGET} PLIST ${PB_AI_LIST}  OPTS ${PB_AI_OPTS}   PROTOC_OUT_DIR ${PB_CPP_DIR}/ai )
#GRPC
#proto_gen_grpc(TARGET ${PB_TARGET} PLIST ${PB_AI_LIST}  OPTS ${PB_AI_OPTS}   PROTOC_OUT_DIR ${PB_CPP_DIR}/ai )

list(APPEND PB_AI_DOC_LIST ${PB_AI_LIST})
proto_gen_doc(TARGET ${PB_TARGET}
                PLIST ${PB_AI_DOC_LIST}
                OPTS ${PB_AI_OPTS}
                OPTS --doc_opt=markdown,photo.md,"AI服务接口定义"
                PROTOC_OUT_DIR ${PB_DOC_DIR})